home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / include / sys / types.h < prev    next >
C/C++ Source or Header  |  1992-11-13  |  3KB  |  130 lines

  1. /*
  2.  * Copyright (c) 1982 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  *
  6.  *    @(#)types.h    7.3 (Berkeley) 6/20/87
  7.  *  $Header: /sprite/src/lib/include/sys/RCS/types.h,v 1.18 92/11/13 11:28:06 mottsmth Exp $
  8.  */
  9.  
  10. #ifndef _TYPES
  11. #define    _TYPES
  12. /*
  13.  * Basic system types and major/minor device constructing/busting macros.
  14.  *
  15.  * Note that these are also defined as unix_major and unix_minor to
  16.  * avoid conflict with the major and minor fields in the Fs_FileID struct.
  17.  * That structure is defined in <fs.h>, which undefines the major() and
  18.  * minor() macros if you aren't using an ANSI C compiler like gcc.
  19.  */
  20. #ifndef KERNEL
  21. /* major part of a device */
  22. #define    major(x)    ((int)(((unsigned)(x)>>8)&0377))
  23. #endif
  24. #define unix_major(x)    ((int)(((unsigned)(x)>>8)&0377))
  25.  
  26. #ifndef KERNEL
  27. /* minor part of a device */
  28. #define    minor(x)    ((int)((x)&0377))
  29. #endif
  30. #define    unix_minor(x)    ((int)((x)&0377))
  31.  
  32. /* make a device number */
  33. #define    makedev(x,y)    ((dev_t)(((x)<<8) | (y)))
  34.  
  35. typedef    unsigned char    u_char;
  36. typedef    unsigned short    u_short;
  37. typedef    unsigned int    u_int;
  38. typedef    unsigned long    u_long;
  39. typedef    unsigned short    ushort;        /* sys III compat */
  40.  
  41. #if defined(vax) || defined(tahoe)
  42. typedef    struct    _physadr { int r[1]; } *physadr;
  43. typedef    struct    label_t    {
  44.     int    val[14];
  45. } label_t;
  46. #endif
  47. #if defined(mc68000)
  48. typedef    struct    _physadr { short r[1]; } *physadr;
  49. typedef    struct    label_t    {
  50.     int    val[13];
  51. } label_t;
  52. #endif
  53.  
  54. #if defined(mips)
  55. typedef struct  _physadr { int r[1]; } *physadr;
  56. typedef struct  label_t {
  57.         int     val[12];
  58. } label_t;
  59. #endif mips
  60.  
  61. /* 
  62.  * See <quad.h> for operations on these data types.
  63.  */
  64. typedef struct _quad {long val[2]; } quad;
  65. typedef    struct    _uquad {unsigned long val[2]; } u_quad;
  66.  
  67. typedef    long    daddr_t;
  68. typedef    char *    caddr_t;
  69. typedef    long *    qaddr_t;    /* should be typedef quad * qaddr_t; */
  70. typedef    u_long    ino_t;
  71. typedef    long    swblk_t;
  72. #ifndef _MODE_T
  73. #define _MODE_T
  74. typedef    unsigned short  mode_t;
  75. #endif
  76. #ifndef _SIZE_T
  77. #define _SIZE_T
  78. typedef    int    size_t;
  79. #endif
  80. #ifndef _TIME_T
  81. #define _TIME_T
  82. typedef    long    time_t;
  83. #endif
  84. #ifndef _CLOCK_T
  85. #define _CLOCK_T
  86. typedef    long    clock_t;
  87. #endif
  88. typedef    short    dev_t;
  89. typedef    long    off_t;
  90. typedef    short    uid_t;
  91. typedef    short    gid_t;
  92. /* 
  93.  * A Sprite Proc_PID is an unsigned int, but UNIX code expects to be able 
  94.  * to check for pid's that are less than 0 (e.g., error return from 
  95.  * fork()), so we make pid_t be signed.
  96.  */
  97. #ifndef _PID_T
  98. #define _PID_T
  99. typedef int    pid_t;
  100. #endif
  101. typedef long    key_t;        /* sys V compat */
  102.  
  103. #define    NBBY    8        /* number of bits in a byte */
  104. /*
  105.  * Select uses bit masks of file descriptors in longs.
  106.  * These macros manipulate such bit fields (the filesystem macros use chars).
  107.  * FD_SETSIZE may be defined by the user, but the default here
  108.  * should be >= NOFILE (param.h).
  109.  */
  110. #ifndef    FD_SETSIZE
  111. #define    FD_SETSIZE    256
  112. #endif
  113.  
  114. typedef long    fd_mask;
  115. #define NFDBITS    (sizeof(fd_mask) * NBBY)    /* bits per mask */
  116. #ifndef howmany
  117. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  118. #endif
  119.  
  120. typedef    struct fd_set {
  121.     fd_mask    fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  122. } fd_set;
  123.  
  124. #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  125. #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  126. #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  127. #define FD_ZERO(p)    bzero((char *)(p), sizeof(*(p)))
  128.  
  129. #endif /* _TYPES */
  130.